package cc.rengu.igas.momp.common.dao.impl;

import cc.rengu.igas.momp.common.dao.StatCashierUserInfoMapper;
import cc.rengu.igas.momp.common.entity.CcbMcDetailListInObj;
import cc.rengu.igas.momp.common.entity.CcbMcDetailListOutObj;
import cc.rengu.igas.momp.common.entity.TMStatCcbUser;
import cc.rengu.oltp.service.common.constant.AppConfigConstant;
import cc.rengu.oltp.service.common.constant.AppParamConstant;
import cc.rengu.oltp.utility.bean.PageInfo;
import cc.rengu.oltp.utility.bean.PageResult;
import cc.rengu.oltp.utility.util.DbsUtil;
import cc.rengu.oltp.utility.util.XmlConfigUtil;
import cc.rengu.oltp.utility.util.XmlTreeUtil;
import cc.rengu.utility.cache.UnifiedCache;
import cc.rengu.utility.log.RgLog;
import cc.rengu.utility.log.RgLogger;

import java.util.List;

/**
 * @author Jinan Liu
 * @date 2020/4/8 11:09
 * @description
 */
public class StatCashierUserInfoMapperImpl implements StatCashierUserInfoMapper {

    private RgLogger rglog = RgLog.getLogger(this.getClass().getName());
    String dbPoolName = XmlConfigUtil.getXmlConfigCacheKeyValue(AppParamConstant.DATABASE_CONF_NODE, AppConfigConstant.MOMP_POOL_NAME);

    /**
     * 查询商户所属收银员收银员返现明细数据库操作接口实现
     *
     * @param instId  法人机构号
     * @param mcNo    营销活动编号
     * @param mchntNo
     * @return java.util.List<cc.rengu.igas.momp.common.entity.TMStatCcbUser>
     * @throws Exception 异常信息
     * @author Jinan Liu
     * @since 2020/4/8 15:02
     */
    @Override
    public List<TMStatCcbUser> selectMchntCashierCashbackStat(String instId, String mcNo, String mchntNo) throws Exception {
        return null;
    }

    /**
     * 商户查询收银员返现明细列表信息数据库操作接口实现(使用商户编号)
     *
     * @param ccbMcDetailListInObj 收银员返现活动明细列表查询使用实体类入参
     * @param pageInfo             数据库操作分页实体类
     * @return cc.rengu.oltp.utility.bean.PageResult 查询结果列表
     * @throws Exception 异常信息
     * @author Jinan Liu
     * @date 2020/5/28 00:04
     */
    @Override
    public PageResult selectCashierCashbackDetailAll(CcbMcDetailListInObj ccbMcDetailListInObj, PageInfo pageInfo) throws Exception {

        XmlTreeUtil xmlTreeUtil = new XmlTreeUtil();
        String corporation = xmlTreeUtil.getXmlTreeStringValue(AppParamConstant.CORPORATION);
        if (null != corporation && !corporation.isEmpty()) {
            String dbPoolCashNode = corporation.trim() + AppParamConstant.DATABASE_CONF_NODE;
            dbPoolName = XmlConfigUtil.getXmlConfigCacheKeyValue(dbPoolCashNode, AppConfigConstant.MOMP_POOL_NAME);
        }
        rglog.error("DBPoolName=[{}]", dbPoolName);

        DbsUtil dbsUtil = new DbsUtil(dbPoolName);
        String sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "selectMchntCashierCashbackStat");

        return dbsUtil.dbsFetchPageListData(sqlStr, ccbMcDetailListInObj, CcbMcDetailListOutObj.class, pageInfo);
    }
}
